using System;
using System.Collections.Generic;
using System.Text;
using EFFC.Net.Exceptions;
using EFFC.Net.Interface;


namespace EFFC.Net.Log
{
    public class BatchLog4NetLogger :ILogger
    {
        log4net.ILog logInfo;
        log4net.ILog logDebug;
        log4net.ILog logError;

        private void Init(string _domailtype)
        {
            if (_domailtype == "domain1")
            {
                logInfo = log4net.LogManager.GetLogger("InfoLog_FilePrint");
                logDebug = log4net.LogManager.GetLogger("DebugLog_FilePrint");
                logError = log4net.LogManager.GetLogger("ErrorLog_FilePrint");
            }
            if (_domailtype == "domain2")
            {
                logInfo = log4net.LogManager.GetLogger("InfoLog_LabelPrint");
                logDebug = log4net.LogManager.GetLogger("DebugLog_LabelPrint");
                logError = log4net.LogManager.GetLogger("ErrorLog_LabelPrint");
            }
            if (_domailtype == "domain3")
            {
                logInfo = log4net.LogManager.GetLogger("InfoLog_Email");
                logDebug = log4net.LogManager.GetLogger("DebugLog_Email");
                logError = log4net.LogManager.GetLogger("ErrorLog_Email");
            }
            if (_domailtype == "domain4")
            {
                logInfo = log4net.LogManager.GetLogger("InfoLog_Fax");
                logDebug = log4net.LogManager.GetLogger("DebugLog_Fax");
                logError = log4net.LogManager.GetLogger("ErrorLog_Fax");
            }
            if (_domailtype == "domain5")
            {
                logInfo = log4net.LogManager.GetLogger("InfoLog_SMS");
                logDebug = log4net.LogManager.GetLogger("DebugLog_SMS");
                logError = log4net.LogManager.GetLogger("ErrorLog_SMS");
            }
        }

        public void WriteLog(string msg, string _domailtype)
        {
            Init(_domailtype);
            if (logError.IsErrorEnabled)
            {
                logError.Error(msg);
            }
            logError = null;

        }

        public void debug(string msg, string _domailtype)
        {
            Init(_domailtype);
            if (logDebug.IsDebugEnabled)
            {
                logDebug.Debug(msg);
            }
            logDebug = null;
        }
        public void error(string msg, string _domailtype)
        {
            Init(_domailtype);
            if (logError.IsErrorEnabled)
            {
                logError.Error(msg);
            }
            logError = null;
        }
        public void info(string msg, string _domailtype)
        {
            Init(_domailtype);
            if (logInfo.IsInfoEnabled)
            {
                logInfo.Info(msg);
            }
            logInfo = null;
        }
        


        public void WriteLog(LoggerLevel level, string message)
        {
            
        }


        public void WriteLog(LoggerLevel level, string message, string domainType)
        {
            switch (level)
            {
                case LoggerLevel.DEBUG:
                    this.debug(message, domainType);
                    break;
                case LoggerLevel.ERROR:
                    this.error(message, domainType);
                    break;
                case LoggerLevel.INFO:
                    this.info(message, domainType);
                    break;
                default:
                    break;
            }
        }
    }
}
